import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { LoginUsers, Users } from './data/user';
import { Cards } from './data/card';
import { orders } from './data/order'
import { taoCan } from './data/taocan'
import { summary } from './data/recharge_summary'
import { companyApiConfig } from './data/companyGroup'
import { CardBalanceSegs } from './data/cardBalanceShow'
import { ExcessFlow } from './data/ExcessFlowInfo'

let _taoCan = taoCan;
let _Orders = orders;
let _Users = Users;
let _Cards = Cards;
let _Summary = summary;
let _companyApiConfig = companyApiConfig;
let _cardBalanceShow = CardBalanceSegs;
let _ExcessFlow = ExcessFlow;

export default {
    /**
     * mock bootstrap
     */
    bootstrap() {
        let mock = new MockAdapter(axios);

        // mock success request
        mock.onGet('/success').reply(200, {
            msg: 'success'
        });

        // mock error request
        mock.onGet('/error').reply(500, {
            msg: 'failure'
        });

        //登录
        mock.onPost('/api/user/login').reply(config => {
            let { username, password } = JSON.parse(config.data);
            return new Promise((resolve, reject) => {
                let data = null;
                setTimeout(() => {
                    let hasUser = LoginUsers.some(u => {
                        if (u.username === username && u.password === password) {
                            data = JSON.parse(JSON.stringify(u));
                            data.password = undefined;
                            return true;
                        }
                    });
                    //data={"userid":1,"userlevel":"0"};
                    if (hasUser) {
                        resolve([200, { code: 0, msg: '请求成功', data }]);
                    } else {
                        resolve([200, { code: 4001, msg: '账号或密码错误' }]);
                    }
                }, 1000);
            });
        });


        //获取验证码状态(模拟data为空，则为不启用验证码)
        mock.onGet('/api/user/login/validcode/status/info').reply(200, { code: 0, msg: '' });
        //退出登录
        mock.onGet('/api/user/logout').reply(200, { code: 0, msg: '' });
        //查询用户的详细信息
        mock.onGet('/api/user/detail').reply(200, { code: 0, msg: '', data: { "username": "admin", "userlevel": "0", "contactMan": "赵子龙", "contactMobile": "13803831221", "regTime": "2017-04-08 14:14:29.0", "f_contactMan": null, "f_contactMobile": null } });
        //修改用户密码
        mock.onGet('/api/user/editpwd').reply(config => {
            let { username, password } = JSON.parse(config.data);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, { code: 0, msg: '请求成功' }]);
                }, 1000);
            });
        });
        //修改用户手机号
        mock.onGet('/api/user/editmobile').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, { code: 0, msg: '修改成功' }]);
                }, 1000);
            });
        });


        //查询用户的卡报表统计信息
        mock.onGet('/api/report/cardstat').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: { "activeCardSum": 4120, "allCardSum": 5008, "stopCardSum": 10800, "normalCardSum": 1256, "expireCardSum": 300000, "flowWarmingSum": 200 }
                    }]);
                }, 500);
            });
        });


        //获取集团客户GPRS的统计信息
        mock.onGet('/api/report/gprsstat').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: [
                            { "usernum": "20000", "apiname": "康明", "usedgprs": "4000.0", "totalgprs": "20480.0" },
                            { "usernum": "20000", "apiname": "科骏达", "usedgprs": "4000.0", "totalgprs": "20480.0" },
                            { "usernum": "20000", "apiname": "云卡", "usedgprs": "4000.0", "totalgprs": "20480.0" }
                        ]
                    }]);
                }, 500);
            });
        });

        //获取用户列表
        mock.onGet('/user/list').reply(config => {
            let { name } = config.params;
            let mockUsers = _Users.filter(user => {
                if (name && user.name.indexOf(name) == -1) return false;
                return true;
            });
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        users: mockUsers
                    }]);
                }, 1000);
            });
        });



        //获取用户列表（分页）
        mock.onGet('/user/listpage').reply(config => {
            let { page, name } = config.params;
            let mockUsers = _Users.filter(user => {
                if (name && user.name.indexOf(name) == -1) return false;
                return true;
            });
            let total = mockUsers.length;
            mockUsers = mockUsers.filter((u, index) => index < 20 * page && index >= 20 * (page - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        total: total,
                        users: mockUsers
                    }]);
                }, 1000);
            });
        });


        mock.onGet('/api/user/likeusers').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            "pageNum": 1,
                            "pageSize": 10,
                            "size": 10,
                            "orderBy": null,
                            "startRow": 1,
                            "endRow": 10,
                            "total": 100000,
                            "pages": 10000,
                            "list": [{
                                    "userid": 1,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538000"
                                },
                                {
                                    "userid": 2,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 3,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 4,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "1",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 5,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "2",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 6,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 7,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "1",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 8,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 9,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                },
                                {
                                    "userid": 10,
                                    "servicerName": "郑州二七区服务商",
                                    "username": "admin",
                                    "password": "123456",
                                    "userlevel": "0",
                                    "contactMan": "赵子龙",
                                    "contactMobile": "13803821224",
                                    "regTime": "2017-04-08 14:14:29.0",
                                    "f_contactMan": "王书麒",
                                    "f_contactMobile": "15824385514",
                                    "cardnum": "1538"
                                }
                            ],
                            "firstPage": 1,
                            "prePage": 0,
                            "nextPage": 2,
                            "lastPage": 8,
                            "isFirstPage": true,
                            "isLastPage": false,
                            "hasPreviousPage": false,
                            "hasNextPage": true,
                            "navigatePages": 8,
                            "navigatepageNums": [
                                1,
                                2,
                                3,
                                4,
                                5,
                                6,
                                7,
                                8
                            ]
                        }




                    }]);
                }, 500);
            });
        });





        //删除用户
        mock.onGet('/api/user/remove').reply(config => {
            let { id } = config.params;
            _Users = _Users.filter(u => u.id !== id);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 200,
                        msg: '删除成功'
                    }]);
                }, 500);
            });
        });

        //批量删除用户
        mock.onGet('/user/batchremove').reply(config => {
            let { ids } = config.params;
            ids = ids.split(',');
            _Users = _Users.filter(u => !ids.includes(u.id));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 200,
                        msg: '删除成功'
                    }]);
                }, 500);
            });
        });

        //编辑用户
        mock.onPost('/api/user/edit').reply(config => {
            /*
            let { id, name, addr, age, birth, sex } = config.params;
            _Users.some(u => {
              if (u.id === id) {
                u.name = name;
                u.addr = addr;
                u.age = age;
                u.birth = birth;
                u.sex = sex;
                return true;
              }
            });
            */
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 200,
                        msg: '编辑成功'
                    }]);
                }, 500);
            });
        });

        //新增用户
        mock.onPost('/api/user/add').reply(config => {
            /*
            let { name, addr, age, birth, sex } = config.params;
            _Users.push({
              name: name,
              addr: addr,
              age: age,
              birth: birth,
              sex: sex
            });
            */
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 200,
                        msg: '新增成功'
                    }]);
                }, 500);
            });
        });


        //模糊查询匹配的查询管理列表
        mock.onGet('/api/cards/like').reply(config => {
            let { pageNum, pageSize, likeCardKey } = config.params;
            let mockCards = _Cards.filter(card => {
                if (likeCardKey && card.PACKAGENAME.indexOf(likeCardKey) == -1) return false;
                return true;
            });
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });

        //查询即将到期的卡列表
        mock.onGet('/api/cards/getCarListByExpire').reply(config => {
            let { pageNum, pageSize, likeCardKey } = config.params;
            let mockCards = _Cards.filter(card => {
                if (likeCardKey && card.PACKAGENAME.indexOf(likeCardKey) == -1) return false;
                return true;
            });
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });


        //模糊查询匹配的入库管理列表
        mock.onGet('/api/cards/likeinsku').reply(config => {
            let { pageNum, pageSize, likeCardKey } = config.params;
            let mockCards = _Cards.filter(card => {
                if (likeCardKey && card.PACKAGENAME.indexOf(likeCardKey) == -1) return false;
                return true;
            });
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });


        //模糊查询匹配的出库管理列表
        mock.onGet('/api/cards/likeoutsku').reply(config => {
            let { pageNum, pageSize, likeCardKey } = config.params;
            let mockCards = _Cards.filter(card => {
                if (likeCardKey && card.PACKAGENAME.indexOf(likeCardKey) == -1) return false;
                return true;
            });
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });


        //删除卡号
        mock.onGet('/api/cards/remove').reply(config => {
            let { cardId } = config.params;
            _Cards = _Cards.filter(u => u.id !== cardId);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '删除成功'
                    }]);
                }, 500);
            });
        });

        //到期号码延期
        mock.onGet('/api/cards/editCardExpiretime').reply(config => {
            let { cardId } = config.params;
            _Cards = _Cards.filter(u => u.id !== cardId);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '延期成功'
                    }]);
                }, 500);
            });
        });

        //批量删除卡号
        mock.onGet('/api/cards/range/remove').reply(config => {
            //let { id } = config.params;
            //_Cards = _Cards.filter(u => u.id !== id);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '删除成功',
                        data: 5
                    }]);
                }, 500);
            });
        });

        //出库卡号
        mock.onGet('/api/cards/outsku').reply(config => {
            // let { cardId } = config.params;
            // _Cards = _Cards.filter(u => u.id !== cardId);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '出库成功'
                    }]);
                }, 500);
            });
        });

        //批量出库卡号
        mock.onGet('/api/cards/range/outsku').reply(config => {
            //let { id } = config.params;
            //_Cards = _Cards.filter(u => u.id !== id);
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '出库成功'
                    }]);
                }, 500);
            });
        });



        //获取用户拥有某个号段卡内的实际数量
        mock.onGet('/api/cards/range/skunum').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '查询成功',
                        data: 5
                    }]);
                }, 500);
            });
        });


        //获取用户的直接下级服务商列表
        mock.onGet('/api/user/childusers').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: [{
                            "userid": 1,
                            "servicerName": "郑州二七区服务商"
                        }, {
                            "userid": 2,
                            "servicerName": "郑州金水区服务商"
                        }, {
                            "userid": 3,
                            "servicerName": "郑州高新区服务商"
                        }]
                    }]);
                }, 500);
            });
        });


        //获取所有的套餐列表
        mock.onGet('/api/dict/packlist').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: [{
                            "packname": "GPRS 10元包月套餐"
                        }, {
                            "packname": "GPRS 20元包月套餐"
                        }, {
                            "packname": "GPRS 30元包月套餐"
                        }]
                    }]);
                }, 500);
            });
        });


        //获取所有的对接第三方同步接口的应用编码列表
        mock.onGet('/api/dict/appsynlist').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: [
                            { "apiname": "郑州地区", "apicode": "0371" },
                            { "apiname": "安阳地区", "apicode": "0372" }
                        ]
                    }]);
                }, 500);
            });
        });


        //批量编辑卡号
        mock.onGet('/api/cards/range/edit').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '修改成功'
                    }]);
                }, 500);
            });
        });


        //查询卡号详细信息
        mock.onGet('/api/cards/detail').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200,
                        {
                            "code": 0,
                            "msg": "",
                            "data": {
                                "querycode": "123456",
                                "smssign": "否",
                                "gprsused": "8000",
                                "gprssign": "是",
                                "packname": "GPRS10元套餐(2020)",
                                "openstate": "开机(2008)",
                                "smsmonthused": "2000(2012)",
                                "imsi": "460040260908676",
                                "outskutime": "2016-10-16",
                                "gprsnow": "2000",
                                "activetime": "2016-12-05 15:41:38",
                                "iccid": "898602B2221430000006",
                                "balance": "11.32(2011)",
                                "apicode": "0371",
                                "servicername": "郑州二七区服务商",
                                "inskutime": "2016-10-15",
                                "msisdn": 13803831221,
                                "gprstotal": "100",
                                "cardstate": "单向停机(2002)",
                                "lastsyntime": "2016-10-19 15:24:36",
                                "innettype": "4G(2001)",
                                "ip": "10.56.129.64(2001)",
                                "apn": "cmmtm(2001)",
                                "remark": "豫A6338G",
                                "expiretime": "2016-10-19",
                                "rechargePrice": "500.12",
                                "openAccountTime": "2016-10-19"
                            }
                        }
                    ]);
                }, 500);
            });
        });


        //上传导入EXCEL文件数据
        mock.onPost('/api/cards/excel/imp').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '入库成功'
                    }]);
                }, 500);
            });
        });


        //上传批量激活EXCEL文件数据
        mock.onPost('/api/cards/excel/impbatchactive').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '入库成功'
                    }]);
                }, 500);
            });
        });

        //上传批量延期续费EXCEL文件数据
        mock.onPost('/api/cards/excel/impbatchexpire').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '入库成功'
                    }]);
                }, 500);
            });
        });

        //上传批量更改卡号的集团归属EXCEL文件数据
        mock.onPost('/api/cards/excel/impbatchapicode').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '批量修改卡号的集团归属成功'
                    }]);
                }, 500);
            });
        });

        //上传批量更新卡号EXCEL文件数据
        mock.onPost('/api/cards/excel/ImpBatchMsisdn').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '入库成功'
                    }]);
                }, 500);
            });
        });

        //上传批量修改套餐EXCEL文件数据
        mock.onPost('/api/cards/excel/impbatchpck').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '入库成功'
                    }]);
                }, 500);
            });
        });

        //上传批量更新充值金额信息
        mock.onPost('/api/cards/excel/importPrice').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '更新充值金额成功'
                    }]);
                }, 500);
            });
        });
        //手动同步卡号信息
        mock.onGet('/api/cards/syncard').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '同步成功'
                    }]);
                }, 500);
            });
        });



        //获取卡号自动同步时间
        mock.onGet('/api/dict/getautosyntime').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '查询成功',
                        data: "02:00"
                    }]);
                }, 500);
            });
        });

        //设置卡号自动同步时间
        mock.onGet('/api/user/setsyntime').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '保存成功'
                    }]);
                }, 500);
            });
        });

        //分页显示order信息
        mock.onPost('/api/recharge/getOrderList').reply(config => {
            var order = {
                list: [],
                size: 10,
                total: 31,
            };
            let data = JSON.parse(config.data);
            let page = data.pageNum;
            let pageSize = data.pageSize;
            var j = 0;
            for (let i = (page - 1) * pageSize; i <= (page * pageSize) - 1; i++) {
                order.list[j] = _Orders[i];
                j++;
            }
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '查询',
                        data: order,
                    }]);
                }, 500);
            });
        });

        //获取模糊查询套餐的分页列表
        mock.onGet('/api/package/like').reply(config => {
            var taocan = {
                list: [],
                size: 10,
                total: 70,
            };
            let { pageNum } = config.params;
            let { pageSize } = config.params;

            let page = pageNum;
            var j = 0;
            for (let i = (page - 1) * pageSize; i <= (page * pageSize) - 1; i++) {
                taocan.list[j] = _taoCan[i];
                j++;
            }
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '查询',
                        data: taocan,
                    }]);
                }, 500);
            });
        });

        //获取所有的套餐列表
        mock.onGet('/api/package/getlist').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: _taoCan
                    }]);
                }, 500);
            });
        });


        //新增套餐
        mock.onPost('/api/package/savePakage').reply(config => {
            var data = JSON.parse(config.data);
            var Mymsg = "";
            if (data.updateStatus == 0) {
                Mymsg = "添加成功";
            } else {
                Mymsg = "修改成功";
            }
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: Mymsg,
                    }]);
                }, 500);
            });
        });

        //删除指定的套餐
        mock.onGet('/api/package/delPakageById').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '删除成功',
                    }]);
                }, 500);
            });
        });
        //分页显示汇总信息
        mock.onGet('/api/summary/getSummaryList').reply(config => {
            let { pageNum } = config.params;
            let { pageSize } = config.params;
            var result = {
                list: [],
                size: pageSize,
                total: _Summary.length,
            };
            let page = pageNum;
            var j = 0;
            console.log(config.params);
            for (let i = (page - 1) * pageSize; i <= (page * pageSize) - 1; i++) {
                result.list[j] = _Summary[i];
                j++;
            }
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '查询',
                        data: result,
                    }]);
                }, 500);
            });
        });
        //批量导出卡信息（根据提供的卡编号集合）
        mock.onPost('/api/cards/bathExportCard').reply(config => {
            return new Promise((resolve, reject) => {
                console.log(config);
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '导出成功，请下载',
                    }]);
                }, 500);
            });
        });
        //批量开关机
        mock.onPost('/api/cards/bathsuspendCard').reply(config => {
            return new Promise((resolve, reject) => {
                console.log(config);
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '批量开关机成功',
                    }]);
                }, 500);
            });
        });
        //批量数据开关
        mock.onPost('/api/cards/bathdataStateUp').reply(config => {
            return new Promise((resolve, reject) => {
                console.log(config);
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '批量数据开关成功',
                    }]);
                }, 500);
            });
        });
        //批量转为计费期
        mock.onPost('/api/cards/bathtocharging').reply(config => {
            return new Promise((resolve, reject) => {
                console.log(config);
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '批量转为计费期成功',
                    }]);
                }, 500);
            });
        });



        //批量删除卡信息（根据提供的卡编号集合）
        mock.onPost('/api/cards/bathDelCards').reply(config => {
            return new Promise((resolve, reject) => {
                console.log(config);
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '删除了55条数据',
                    }]);
                }, 1000);
            });
        });



        //获取模糊查询的集团客户API配置信息分页列表
        mock.onGet('/api/companyapiconfig/like').reply(config => {
            let { pageNum } = config.params;
            let { pageSize } = config.params;
            var result = {
                list: [],
                size: pageSize,
                total: _companyApiConfig.length,
            };
            let page = pageNum;
            var j = 0;
            console.log(config.params);
            for (let i = (page - 1) * pageSize; i <= (page * pageSize) - 1; i++) {
                result.list[j] = _companyApiConfig[i];
                j++;
            }
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '查询',
                        data: result,
                    }]);
                }, 500);
            });
        });


        //编辑用户
        mock.onPost('/api/companyapiconfig/edit').reply(config => {

            let { apicode, apiname, appcode, apppwd, isautosyn, usedgprsmore } = config;
            _companyApiConfig.some(u => {
                if (u.apicode === apicode) {
                    u.apiname = apiname;
                    u.appcode = appcode;
                    u.apppwd = apppwd;
                    u.isautosyn = isautosyn;
                    u.usedgprsmore = usedgprsmore;
                    return true;
                }
            });

            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '编辑成功'
                    }]);
                }, 500);
            });
        });

        //新增用户
        mock.onPost('/api/companyapiconfig/add').reply(config => {

            let { apicode, apiname, appcode, apppwd, isautosyn, usedgprsmore } = config;
            _companyApiConfig.push({
                apicode: apicode,
                apiname: apiname,
                appcode: appcode,
                apppwd: apppwd,
                isautosyn: isautosyn,
                usedgprsmore: usedgprsmore
            });

            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '新增成功'
                    }]);
                }, 500);
            });
        });



        //获取模糊查询所有已屏蔽用户余额的卡号的分页列表
        mock.onGet('/api/cards/likeNoBalance').reply(config => {
            let { pageNum, pageSize, likeCardKey } = config.params;
            let mockCards = _Cards.filter(card => {
                if (likeCardKey && card.PACKAGENAME.indexOf(likeCardKey) == -1) return false;
                return true;
            });
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });


        ////获取已屏蔽用户余额的卡号段的分页列表
        mock.onGet('/api/cards/balance/likeNoshow').reply(config => {
            let { pageNum, pageSize, likeCardKey } = config.params;
            let mockCards = _cardBalanceShow.filter(card => {
                if (likeCardKey && card.PACKAGENAME.indexOf(likeCardKey) == -1) return false;
                return true;
            });
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });

        //增加屏蔽指定卡段内的卡号，在微信不能看用户余额
        mock.onGet('/api/cards/balance/addNoshow').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '成功屏蔽卡号段'
                    }]);
                }, 500);
            });
        });


        //删除屏蔽指定卡段内的卡号，在微信不能看用户余额
        mock.onGet('/api/cards/balance/delNoshow').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '成功解除限制'
                    }]);
                }, 500);
            });
        });
        //更新卡信息的备注和到期时间
        mock.onPost('/api/cards/updateCardinfo').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '修改成功'
                    }]);
                }, 500);
            });

        });
        //查询超过当前月份流量阀值的信息
        mock.onGet('/api/excessflow/getAllinfo').reply(config => {
            // let { pageNum, pageSize, likeCardKey } = config.params;
            let { pageNum, pageSize, likeCardKey } = config.params;
            let flowInfo;
            let total = _ExcessFlow.length;
            flowInfo = _ExcessFlow.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: flowInfo
                        }
                    }]);
                }, 1000);
            });
        });
        //批量编辑卡号
        mock.onGet('/api/cards/range/edit').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '修改成功'
                    }]);
                }, 500);
            });
        });


        //查询流量阀值详情信息
        mock.onGet('/api/excessflow/getFlowDetail').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200,
                        {
                            "code": 0,
                            "msg": "",
                            "data": {
                                "flowid": "2",
                                "excessflow": 100.22,
                                "flowmonth": "2018-04",
                                "msisdn": "14764691325",
                                "iccid": "898600D69815C0034261",
                                "imsi": "460079646909261",
                                "userid": "2",
                                "gprsnow": null,
                                "flowthreshold": 0.0,
                                "apicode": "KANGMING",
                                "querycode": "K00087",
                                "servicename": "三门峡汪玮",
                                "gprsused": 0.0
                            }
                        }
                    ]);
                }, 500);
            });
        });

        //批量预充值
        mock.onPost('/api/tRechargeTemp/excel/bathRecharge').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '批量预充值入库成功，请使用微信进行付款'
                    }]);
                }, 500);
            });
        });

        //查询预充值卡信息列表
        mock.onGet('/api/tRechargeTemp/getAllchargeInfo').reply(config => {
            let { pageNum, pageSize } = config.params;
            let mockCards = _Cards;
            let total = mockCards.length;
            mockCards = mockCards.filter((u, index) => index < pageSize * pageNum && index >= pageSize * (pageNum - 1));
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '请求成功',
                        data: {
                            total: total,
                            list: mockCards
                        }
                    }]);
                }, 1000);
            });
        });
        //查询批量充值金额和订单Id
        mock.onGet('/api/tRechargeTemp/getrechargePrice').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200,
                        {
                            "code": 0,
                            "msg": "",
                            "data": {
                                "orderId": "B180409111236356",
                                "rechargePrice": 100.22
                            }
                        }
                    ]);
                }, 500);
            });
        });

        //获取移动短信列表
        mock.onGet('/api/smsSend/getSmsDetailCmcc').reply(config => {
            var smsList = [
                { "sortNo": "100000001", "cardnum": "155999999999", "content": "短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000002", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000003", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000004", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000005", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000006", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000007", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000008", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000009", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000010", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000011", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" },
                { "sortNo": "100000012", "cardnum": "155999999999", "content": "短信内容", "addtime": "2018-05-13 13:20:30", "directtypeNm": "上行" }
            ];
            let { pageNum } = config.params;
            let { pageSize } = config.params;
            var result = {
                list: [],
                size: pageSize,
                total: smsList.length,
            };
            let page = pageNum;
            var j = 0;
            console.log(config.params);
            for (let i = (page - 1) * pageSize; i <= (page * pageSize) - 1; i++) {
                result.list[j] = smsList[i];
                j++;
            }
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200,
                        {
                            "code": 0,
                            "msg": "",
                            "data": result
                        }
                    ]);
                }, 500);
            });
        });

        //发送短信
        mock.onGet('/api/smsSend/send').reply(config => {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve([200, {
                        code: 0,
                        msg: '发送成功'
                    }]);
                }, 500);
            });
        });

    }
};